<script type="text/javascript">
function ValidatePage(frm)
{
	var image = document.getElementById('image').value;
	var page_id = document.getElementById('id').value;

	if(image == "") {
		alert("Upload Images");
		return false;
	}
	else {
		var checkimg = image.toLowerCase();
		if (image != "" && !checkimg.match(/(\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG|\.jpeg|\.JPEG)$/)) {

			alert("Please select JPG, PNG or GIF Picture only");
			return false;
		}
		else {
			if(page_id == "") {
				document.getElementById('process').value = 'add';
			}
			else {
				document.getElementById('process').value = 'edit';
			}
		}
		document.frm.submit();
	}
	return false;
}
</script>
<?php
$query = mysql_query("select `id`, `page_name`, `title`, `image`, `stored_image_name`, `active_status` 
					 from manage_images where id='".$_REQUEST['_d']."'") or die(mysql_error());

$res = mysql_fetch_array($query);

if($res["active_status"] == 1) 
{
	$active_status = "checked";
}
else 
{
	$deactive_status = "checked";
}
?>
<table border="0" width="100%" align="center">
<tr>
	<td width="46%" align="left"><span style="color:#1B78B7; font-size:14px; font-weight:bold">
    Add Page</span>&nbsp; 
	<!--<input type="button" name="addnew" value="Add New" onclick="return show();" />-->
	</td>
	<td width="40%" align="right" class="font12">
    <a href="index.php" class="font12">Manage Pages</a></td>
</tr>
<tr>
	<td background="images/topline.gif" colspan="3" height="11"></td>
</tr>    
</table>
<form name="formPage" method="post" action="action.php" enctype="multipart/form-data" onSubmit="return ValidatePage(this);">
<table width="99%" align="center" border="0"  class="list">
<tr>
	<td align="right" width="250">Image Name</td>
    <td align="left"><input class="text" name="image_name"  id="image_name" type="text" value="<?php echo $res['title'];?>"/></td>
</tr>
<tr>
	<td align="right" width="250">URL</td>
    <td align="left"><input class="text" name="url"  id="url" type="text" value="<?php echo $res['url'];?>"/></td>
</tr>
<tr>
	<td align="right" width="250">Upload Image*</td>
    <td align="left"><input class="text" name="image" id="image" type="file" value="<?php echo $res['meta_title'];?>"/></td>
</tr>


<tr>
  <td align="right" width="150">Status :</td>
  <td align="left">
  <input name="authorised" type="radio" class="text" value=1 <?php echo $active_status;?> />&nbsp;Active&nbsp;&nbsp;
  <input class="text" name="authorised" type="radio" value=0 <?php echo $deactive_status;?>/>&nbsp;Deactive</td>
</tr>
<tr>
	<td align="right" width="150"></td>
    <td align="left">
    
    <input name="old_image_name" id="old_image_name" type="hidden" value="<?php echo $res['stored_image_name'];?>"/>
    <input name="id" id="id" type="hidden" value="<?php echo $res['id'];?>"/>
    <input name="module" id="module" type="hidden" value="images"/>
    <input name="process" id="process" type="hidden" value=""/>
    <input type="submit" value="Submit" name="save_gadgettech">&nbsp;<input type="reset" name="reset" value="Clear" /></td>
</tr>
</table>
</form>